<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="text" id="i2">
<button onclick="f1()">加</button>
<button onclick="f2()">减</button>
<button onclick="f3()">乘</button>
<button onclick="f4()">除</button>
<h1>结果：<span></span></h1>
<script>
  let i1 = document.querySelector("#i1");
  let i2 = document.querySelector("#i2");
  let result = document.querySelector("span");
  function f1() {
      if(isNaN(i1.value) || isNaN(i2.value)){
          result.innerText = "输入错误，请输入数字"
          return;
      }
    result.innerText = parseFloat(i1.value)+parseFloat(i2.value);
  }
  function f2() {
      if(isNaN(i1.value) || isNaN(i2.value)){
          result.innerText = "输入错误，请输入数字"
          return;
      }
      result.innerText = i1.value-i2.value;
  }
  function f3() {
      if(isNaN(i1.value) || isNaN(i2.value)){
          result.innerText = "输入错误，请输入数字"
          return;
      }
      result.innerText = i1.value*i2.value;
  }
  function f4() {
      if(isNaN(i1.value) || isNaN(i2.value)){
          result.innerText = "输入错误，请输入数字"
          return;
      }
      result.innerText = i1.value/i2.value;
  }


</script>
</body>
</html>